﻿var theme;
var postfix;
var LPcellSize;
var tableCellDefaultDisplay;
var isIE7;

function Init(themeName, cookiePostfix) {
    theme = themeName;
    postfix = cookiePostfix;
    isIE7 = __aspxIE && __aspxBrowserVersion == 7;
}
function OnMouseEnter(separatorButtonId) {
    var separatorButton = document.getElementById(separatorButtonId);
    separatorButton.className += (' dxsplVSeparatorButtonHover_' + theme);
}
function OnMouseLeave(separatorButtonId) {
    var separatorButton = document.getElementById(separatorButtonId);
    separatorButton.className = 'dxsplVSeparatorButton_' + theme;
}
function UpdateSeparatorsImages(separatorImageId, collapseLeft, targetPanelDisplay) {
    var separatorImage = document.getElementById(separatorImageId);
    if (collapseLeft) {
        separatorImage.className = (targetPanelDisplay == 'none' ? 'dxWeb_splVCollapseForwardButton_' : 'dxWeb_splVCollapseBackwardButton_');
    }
    else {
        separatorImage.className = (targetPanelDisplay == 'none' ? 'dxWeb_splVCollapseBackwardButton_' : 'dxWeb_splVCollapseForwardButton_');
    }
    separatorImage.className += theme;
}
function OnClick(panelId, separatorImageId, collapseLeft) {
    var LPcell = document.getElementById(panelId);
    LPcell.style.display = (!LPcell.style.display || LPcell.style.display == tableCellDefaultDisplay) ? 'none' : tableCellDefaultDisplay;
    UpdateSeparatorsImages(separatorImageId, collapseLeft, LPcell.style.display);
    _aspxSetCookie(panelId + postfix, LPcell.style.display);
    AdjustSize();
}
function UpdateRightPaneVisibility(rightPanelId, rightSeparatorCell, rightSeparatorImage) {
    var right = document.getElementById(rightPanelId);
    if (right) {
        var separatorDisplay = "none";
        var rightDisplay = "none";
        var isRightEmpty = right.children[0].children.length == 0;
        if (!isRightEmpty) {
            separatorDisplay = "";
            rightDisplay = "";
            var cookieDisplay = _aspxGetCookie(rightPanelId + postfix);
            if (cookieDisplay) {
                rightDisplay = cookieDisplay;
            }
        }
        var separator = document.getElementById(rightSeparatorCell);
        separator.style.display = separatorDisplay;
        right.style.display = rightDisplay;
        UpdateSeparatorsImages(rightSeparatorImage, false, rightDisplay);
    }
}
function OnLoadCore(leftPanelId, rightPanelId, leftSeparatorCell, rightSeparatorCell, leftSeparatorImage, rightSeparatorImage) {
    tableCellDefaultDisplay = isIE7 ? "block" : "table-cell";
    var LPcell = document.getElementById(leftPanelId);
    //B187227
    if (isIE7) {
        LPcell.style.width = "355px";
    }
    var leftPanelDisplay = _aspxGetCookie(leftPanelId + postfix);
    if (leftPanelDisplay) {
        LPcell.style.display = leftPanelDisplay;
    }
    UpdateSeparatorsImages(leftSeparatorImage, true, LPcell.style.display);
    UpdateRightPaneVisibility(rightPanelId, rightSeparatorCell, rightSeparatorImage);
    AdjustSize();
    DXattachEventToElement(window, "resize", AdjustSize);
}
